<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>

<html>
	<head>
		<title>部门材料库存</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$("#type_id").combotree({
				url:'<%=contextPath %>/springMVC/group/getSystemTypeTree?type=1',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					docSearch();
				}
			});
			
			$("#cSearchValue").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 docSearch();
		       	} 
		   	}); 
			$("#searchValue").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
		   	}); 
			$("#xmSearchValue").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
		   	}); 
			$("#material_type_id").combotree({
				url:'<%=contextPath %>/springMVC/group/getSystemTypeTree?type=0',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
			$("#dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
			
			$('#table').datagrid({
				title:"甲供库",
				iconCls:'icon-edit',
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/warehouse/listPageJgDB',
				rownumbers:true,
				fitColumns:true,
				nowrap:false,
				idField:'id',
				frozenColumns:[[
				    {title:'项目id',field:'project_id',hidden:true},
				    {title:'仓库id',field:'warehouse_id',hidden:true},
				    {title:'产品id',field:'product_id',hidden:true}
				]],
				columns:[[
					{title:'部门',field:'dept_name',width:100,align:'center'},
					{title:'项目编号',field:'xm_code',width:100,align:'center'},
					{title:'项目名称',field:'xm_name',width:100,align:'center'},
					{title:'分类',field:'material_type_name',width:80,align:'center'},
					{title:'材料编号',field:'code',width:80,align:'center'},
					{title:'材料名称',field:'name',width:100,align:'center'},
					{title:'规格型号',field:'format_type',width:100,align:'center'},
					{title:'计量单位',field:'unit_name',width:50,align:'center'},
					{title:'库存数量',field:'num',width:50,align:'center'},
					{title:'查看流水',field:'details',width:100,align:'center',formatter: function(value,row,index){
						return "<input type='button'  style='border:0px #ff0000 solid;width:25px;height:15px;cursor:pointer'class='icon-details'  onClick='showLog(\""+row.warehouse_id+"\",\""+row.product_id+"\",\""+row.project_id+"\")'/>";
					}}
				]],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		
		function doSearch()
		{
			var dept_id = $('#dept_id').combotree('getValue');
			var searchValue = $('#searchValue').val();
			var xmSearchValue = $('#xmSearchValue').val();
			var material_type_id = $('#material_type_id').combotree('getValue');
			$('#table').datagrid('load',				
				{
					dept_id:dept_id,
					searchValue:searchValue,
					xmSearchValue:xmSearchValue,
					material_type_id:material_type_id
				}
			);
		}
		function showLog(warehouse_id,product_id,project_id){
			openDialogResize("<%=contextPath %>/springViews/warehouse/dbBeforeDetails.jsp?warehouse_id="+warehouse_id+"&product_id="+product_id+"&project_id="+project_id,1000, 800);
		}
		</script>
	<script type="text/javascript">
	</script>
	<body style="height: 97%">
		<div id="table" data-options="fit:true,toolbar:'#tb'" ></div>
		<div id="tb" style="padding:3px;height:auto">
			<div align="right">
				选择部门：<input  id="dept_id" name="dept_id" class="easyui-combotree">
				分类：<input  id="material_type_id" name="material_type_id" class="easyui-combotree">
				项目编号/名称：<input id="xmSearchValue" name="searchValue" style="width:150px" title="项目编号/名称 " placeholder="项目编号/名称 "/>&nbsp;&nbsp;
				材料编码/名称：<input id="searchValue" name="searchValue" style="width:150px" title=" 材料编码/名称" placeholder="材料编码/名称"/>&nbsp;&nbsp;
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
			</div>
		</div>
	</body>
</html>
